package org.shunfeng.controller;

import org.shunfeng.pojo.Company;
import org.shunfeng.service.CompanyService;
import org.shunfeng.service.UserService;
import org.shunfeng.service.impl.CompanyServiceImpl;
import org.shunfeng.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

@WebServlet("/delivery/toAddDevlivery")
public class ToAddDeliveryPage extends HttpServlet {
    private CompanyService companyService = new CompanyServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            System.out.println("**********/delivery/toAddDevlivery*****************");
            req.setCharacterEncoding("utf-8");
            resp.setContentType("text/html;charset=utf-8");
            List<Company> companies = companyService.queryAllCompany();
            req.setAttribute("companys", companies);
//            req.setAttribute("companys", companyService.queryAllCompany());
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        req.getRequestDispatcher("/add.jsp").forward(req, resp);
    }
}
